package cn.sskxyz.security.authorization.dao;

import cn.sskxyz.mybatis.mode.Page;
import cn.sskxyz.security.authorization.model.Resource;
import cn.sskxyz.security.authorization.model.Role;
import cn.sskxyz.security.authorization.model.RoleResource;
import cn.sskxyz.security.authorization.model.RoleUser;
import cn.sskxyz.security.core.model.User;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface AuthorizationDao {

    void insertRole(Role role);

    void insertRoleUser(RoleUser roleUser);

    void insertRoleResource(RoleResource roleResource);

    List<Role> selectRoleList(Page page);

    /**
     * 根据角色获取所有用户
     *
     * @param roleId
     * @return
     */
    List<User> selectUserListByRoleId(Long roleId);

    /**
     * 根据角色获取权限列表
     *
     * @param roleId
     * @return
     */
    List<Resource> selectResourceListByRoleId(Long roleId);

    List<Role> selectUserRolesByUserId(Long userId);

    List<Resource> selectUserPermissionByUserId(Long userId);

    /**
     * 获取用户在某个模块下可访问的资源列表
     *
     * @param userId
     * @param module
     * @return
     */
    List<Resource> selectUserPermissionByUserIdWithModule(@Param("userId") Long userId, @Param("module") String module);
}
